fix a touchscreen-mode keynav corner case: when navigating to the parent
authorMichael Natterer <mitch@imendio.com>
Tue, 8 Apr 2008 11:03:10 +0000 (11:03 +0000)
committerMichael Natterer <mitch@src.gnome.org>
Tue, 8 Apr 2008 11:03:10 +0000 (11:03 +0000)
2008-04-08  Michael Natterer  <mitch@imendio.com>

* gtk/gtkmenushell.c (gtk_real_menu_shell_move_current): fix a
touchscreen-mode keynav corner case: when navigating to the parent
menu, make sure we don't close two menus at the same time in case
the deepest open menu has no selectable items.

svn path=/trunk/; revision=19981

ChangeLog
gtk/gtkmenushell.c

index 5d090562787b351c7b9e76cacbd71f8dd05c3358..156b6c222236c5d986b665f30c9e917705e19511 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-08  Michael Natterer  <mitch@imendio.com>
+
+       * gtk/gtkmenushell.c (gtk_real_menu_shell_move_current): fix a
+       touchscreen-mode keynav corner case: when navigating to the parent
+       menu, make sure we don't close two menus at the same time in case
+       the deepest open menu has no selectable items.
+
 2008-04-06  Tristan Van Berkom <tvb@gnome.org>
 
        * gtk/gtkwidget.c: Clarified a g_warning message regarding
index 58ce0d73ee9429f5385d5064154e261aeb54c368..595db329dce901e59cd911d1ba763c4112227a56 100644 (file)
@@ -1298,23 +1298,35 @@ gtk_real_menu_shell_move_current (GtkMenuShell         *menu_shell,
 {
   GtkMenuShell *parent_menu_shell = NULL;
   gboolean had_selection;
+  gboolean touchscreen_mode;
 
   had_selection = menu_shell->active_menu_item != NULL;
 
+  g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
+                "gtk-touchscreen-mode", &touchscreen_mode,
+                NULL);
+
   if (menu_shell->parent_menu_shell)
     parent_menu_shell = GTK_MENU_SHELL (menu_shell->parent_menu_shell);
 
   switch (direction)
     {
     case GTK_MENU_DIR_PARENT:
-      if (parent_menu_shell)
+      if (touchscreen_mode &&
+          menu_shell->active_menu_item &&
+          GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu &&
+          GTK_WIDGET_VISIBLE (GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu))
+        {
+          /* if we are on a menu item that has an open submenu but the
+           * focus is not in that submenu (e.g. because it's empty or
+           * has only insensitive items), close that submenu instead
+           * of running into the code below which would close *this*
+           * menu.
+           */
+          _gtk_menu_item_popdown_submenu (menu_shell->active_menu_item);
+        }
+      else if (parent_menu_shell)
        {
-          gboolean touchscreen_mode;
-
-          g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_shell)),
-                        "gtk-touchscreen-mode", &touchscreen_mode,
-                        NULL);
-
           if (touchscreen_mode)
             {
               /* close menu when returning from submenu. */